package com.iot08.admin.kafka;

import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.kafka.core.KafkaTemplate;
import org.springframework.stereotype.Component;

import javax.annotation.Resource;

/**
 * @version 1.0
 * @Description: kafka生产者
 * @time: 2020/9/21 14:43
 * @author: Rock
 * <p>
 * 推送kafka消息
 * @param [message]
 * @time: 2020/9/25 9:02
 * @author: Rock
 * @version 1.0
 * <p>
 * 推送kafka消息
 * @param [key, value]
 * @time: 2020/9/24 17:49
 * @author: Rock
 * @version 1.0
 */
/*@Slf4j
@Component
public class KafkaProducer {

    @Resource
    private KafkaTemplate<String, Object> kafkaTemplate;
    @Value("${kafka.producer.topic-name}")
    private String topicName;

    *//**
 * 推送kafka消息
 * @param [message]
 * @time: 2020/9/25 9:02
 * @author: Rock
 * @version 1.0
 *//*
    public void send(String message){
        log.info(String.format("KafkaProducer send. topic: %s, message: %s", topicName, message));
        kafkaTemplate.send(topicName, message);
        kafkaTemplate.flush();
    }

    *//**
 * 推送kafka消息
 * @param [key, value]
 * @time: 2020/9/24 17:49
 * @author: Rock
 * @version 1.0
 *//*
    public void send(String key, Object value){
        log.info(String.format("KafkaProducer send. topic: %s, key: %s, value: %s", topicName, key, value));
        kafkaTemplate.send(topicName, key, value);
        kafkaTemplate.flush();
    }

}*/
